package com.kingwang.training.designpattern.builder.builder;

import com.kingwang.training.designpattern.builder.bean.CarBody;
import com.kingwang.training.designpattern.builder.bean.Engine;
import com.kingwang.training.designpattern.builder.bean.EngineType;
import com.kingwang.training.designpattern.builder.bean.HammerEngine;
import com.kingwang.training.designpattern.builder.bean.ToyotaEngine;
import com.kingwang.training.designpattern.builder.bean.Wheel;

public class CustomCarBuilder extends CarBuilder {
    private final EngineType engineType;

    public CustomCarBuilder(EngineType engineType) {
        this.engineType = engineType;
    }

    @Override
    public Engine buildEngine() {
        switch (this.engineType) {
            case TOYOTA:
                return new ToyotaEngine();
            case HAMMER:
                return new HammerEngine();
            default:
                throw new IllegalArgumentException("非法的引擎类型");
        }
    }

    @Override
    public CarBody buildBody() {
        return null;
    }

    @Override
    public Wheel buildWheel() {
        return null;
    }
}
